home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / CENTER.INC < prev    next >
Text File  |  1989-06-02  |  956b  |  47 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  *
  15.  * centers a string around a given width
  16.  *
  17.  *)
  18.  
  19. procedure center (var str:       anystring;
  20.                   width:         integer);
  21. var
  22.    front:         integer;
  23.    back:          integer;
  24.  
  25. begin
  26.  
  27.    if length (str)> width then
  28.       str[0]:= chr (width);
  29.  
  30.    back := width - length (str);
  31.    front := back div 2;
  32.    back := back - front;
  33.  
  34.    while front > 0 do
  35.    begin
  36.       str := ' ' + str;
  37.       front := front - 1;
  38.    end;
  39.  
  40.    while back > 0 do
  41.    begin
  42.       str := str + ' ';
  43.       back := back - 1;
  44.    end;
  45. end;
  46.  
  47.